<template>
	<view class="content">
		<navigator class="item" v-for="(item,index) in datas" :key="index" hover-class="false" :url="'packagedetail?package_id='+package_id+'&isSee=1&package_log_id='+item.package_log_id">
			<view class="name">{{item.package_name}}</view>
			<view class="time">{{item.time}}</view>
		</navigator>
		<uni-load-more v-if="datas.length > 6" :status="status" :content-text="contentText" />
	</view>
</template>

<script>
	import util from '../../common/util.js';
	export default{
		data() {
			return {
				package_id: '',
				datas: [],
				page: 1,
				reload: true,
				status: 'more',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多',
					contentnot: "没数据"
				},
				student_id:''
			}
		},
		onPullDownRefresh() {
			this.reload = true;
			this.page = 1;
			this.getList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.status = 'loading';
			this.page = this.page + 1;
			var _this = this;
			setTimeout(function() {
				_this.getList();
			}, 500);
		},
		onLoad(e) {
			this.package_id = e.package_id;
			this.student_id=e.student_id;
			this.getList();
		},
		methods: {
			getList() {
				var data = {
					pagesize: 8,
					page: this.page,
					package_id: this.package_id,
					user_id:this.student_id
				}
				this.$zapi.apiPost('user/package.user/getPackagelogList', data).then(res => {
					if (res.data.code == 200 && res.data.data.data.length > 0) {
						var lists = res.data.data.data;
						for (var i = 0; i < lists.length > 0; i++) {
							lists[i].time = util.getBriefTime(lists[i].creat_time);
						}
						this.datas = this.reload ? lists : this.datas.concat(lists);
						this.reload = false;
						this.status = 'more';
					} else {
						if (this.reload) {
							this.datas = [];
							uni.showToast({
								title: '暂无数据',
								icon: 'none'
							})
						} else {
							this.status = "noMore";
						}
					}
				})
			}
		}
	}
</script>

<style>
	page{
		background-color: #FAFAFA;
	}
	.content{
		width: 690upx;
		margin: 0 auto;
	}
	.item{
		padding: 30upx;
		background: #FFFFFF;
		border-radius: 20upx;
		margin-top: 30upx;
	}
	.name{
		color: #333333;
		font-size: 38upx;
		line-height: 1.5;
	}
	.time{
		color: #999999;
		font-size: 26upx;
		margin-top: 10upx;
	}
</style>
